import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:travel/components/mine/collect.dart';
import 'package:travel/utils/colors.dart';
import 'package:travel/utils/styles.dart';
import 'package:travel/utils/tools.dart';
import 'package:travel/screen/flutter_screenutil.dart';

class MineCollectController extends GetxController with GetTickerProviderStateMixin {
  List<String> tabs = ['景点', '文章', '视频', '酒店'];

  late TabController tabController;

  @override
  void onInit() {
    tabController = TabController(length: tabs.length, vsync: this);
    super.onInit();
  }

  @override
  void onClose() {
    tabController.dispose();
    super.onClose();
  }
}

class MineCollectView extends GetView<MineCollectController> {
  const MineCollectView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF7f7),
      appBar: AppBar(
        backgroundColor: Colors.white,
        automaticallyImplyLeading: true,
        leading: InkWell(
          onTap: () {
            Get.back();
          },
          child: Icon(
            Icons.arrow_back_ios,
            color: ColorsUtils.parseColorFromHexString(ColorsUtils.color3333),
            size: 20.w,
          ),
        ),
        leadingWidth: 40.w,
        title: Center(
          child: Text('我的收藏',
              style: StylesUtils.customTextStyle(
                  color: ColorsUtils.color3333, fontSize: 18.sp, fontWeight: FontWeight.bold)),
        ),
        actions: [
          SizedBox(
            width: 40.w,
          )
        ],
        bottom: bottom,
      ),
      body: TabBarView(
        controller: controller.tabController,
        children: const [
          CollectAttractions(),
          CollectArticle(),
          CollectVideo(),
          CollectHotel(),
        ],
      ),
    );
  }

  PreferredSize get bottom {
    return PreferredSize(
      preferredSize: Size.fromHeight(40.h),
      child: Container(
        height: 40.h,
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    width: 2, color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF5f5)))),
        alignment: Alignment.centerLeft,
        child: ToolsUtils.getClientTabBar(controller.tabs, controller.tabController,
            isScrollable: false, indicatorSize: TabBarIndicatorSize.label),
      ),
    );
  }
}
